<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>在线编程</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/programHome.css">
</head>
<body>

<jsp:include page="../public/header.jsp"/>

<div class="main">
    <div class="sidebar">
        <span class="title">攻克难题</span>
        <ul>
            <c:forEach var="item" items="${requestScope.hot}">
                <li>
                    <a href="${pageContext.request.contextPath}/program/goProgram/${item.programId}">${item.programTitle}</a>
                </li>
            </c:forEach>
        </ul>
    </div>
    <div class="left_bar">
        <h3 class="title">全部编程题目</h3>
        <div class="searchBox">
            <input type="text" class="inputText4" value="${requestScope.kw}" id="Validate" name="Validate" placeholder="根据语言类型搜索">
            <button type="button" class="searchProgram">搜索</button>
            <script>
                let pageNum = ${empty requestScope.pageInfo ? "null" : requestScope.pageInfo.pageNum};
            </script>
        </div>
        <c:choose>
            <c:when test="${!empty requestScope.pageInfo}">
                <table border="1" cellspacing="0" cellpadding="10">
                    <thead>
                    <tr>
                        <td>题目名称</td>
                        <td>难度系数</td>
                        <td>语言类型</td>
                        <td>关键字</td>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach var="program" items="${requestScope.pageInfo.list}">
                        <tr>
                            <td>
                                <a href="${pageContext.request.contextPath}/program/goProgram/${program.programId}">${program.programTitle}</a>
                            </td>
                            <td>
                                <c:forEach step="1" begin="1"
                                        end="${program.programDifficultDegree}">&#9733;</c:forEach>
                            </td>
                            <td>${program.programLanguage}</td>
                            <td>
                                <c:forTokens items="${program.programKeywords}" delims="," var="code">
                                    <span> ${code} </span>
                                </c:forTokens>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <ul class="cell">
                    <li>
                        <c:if test="${requestScope.pageInfo.isFirstPage}">
                            <span class="dis">&laquo;</span>
                        </c:if>
                        <c:if test="${!requestScope.pageInfo.isFirstPage}">
                            <a href="${pageContext.request.contextPath}/dynamic?page=${requestScope.pageInfo.prePage}&kw=${requestScope.kw}">&laquo;</a>
                        </c:if>
                    </li>
                    <c:forEach var="i" begin="1" end="${requestScope.pageInfo.pages}" step="1">
                        <li>
                            <a href="${pageContext.request.contextPath}/dynamic?page=${i}&kw=${requestScope.kw}"
                            class="${i==requestScope.pageInfo.pageNum?"choose":""}">${i}</a>
                        </li>
                    </c:forEach>
                    <li>
                        <c:if test="${requestScope.pageInfo.isLastPage}">
                            <span class="dis">&raquo;</span>
                        </c:if>
                        <c:if test="${!requestScope.pageInfo.isLastPage}">
                            <a href="${pageContext.request.contextPath}/dynamic?page=${requestScope.pageInfo.nextPage}&kw=${requestScope.kw}">&raquo;</a>
                        </c:if>
                    </li>
                </ul>
            </c:when>
            <c:otherwise>
                <ul class="cell">
                    <li style="line-height: 80px;">暂无数据，试试其他的？</li>
                </ul>
            </c:otherwise>
        </c:choose>

    </div>
</div>
<script src="${pageContext.request.contextPath}/js/programHome.js"></script>
<jsp:include page="../public/footer.jsp"/>

</body>
</html>
